package org.zhouhe.web.tag;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.lang.StringUtils;

public class Rows extends TagSupport {
	private static final long serialVersionUID = 1L;
	private boolean frozen = false;
    @Override  
    public int doStartTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			List<String> optList = new ArrayList<String>();
			if(this.frozen){
				optList.add("frozen:true");
			}
			out.write("<thead data-options=\""+ StringUtils.join(optList, ",") +"\"><tr>");
		} catch (Exception e) {
			e.printStackTrace();
		}
    	return EVAL_BODY_INCLUDE;
    } 
    
    @Override  
    public int doEndTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			out.println("</tr></thead>");
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
        return EVAL_PAGE;
    }  

	public boolean isFrozen() {
		return frozen;
	}

	public void setFrozen(boolean frozen) {
		this.frozen = frozen;
	}
}
